#!/usr/bin/env node

const Koa = require('koa'),
      KoaBody = require('koa-body'),
      Router = require('koa-router'),
      {join} = require('path');

const app = new Koa();
const router = new Router();

app.use(KoaBody({
  multipart: true,
  formidable: {
    uploadXDir: join(__dirname, '/routes'),
    keepExtendsions: true
  }
}));

router.post('/file', async (ctx, next) => {
  const file = ctx.request.files;
  ctx.body = {path: file}
})

app.use(router.routes())
app.listen(3000)
      
